package com.gimi.cloud.bbp.manage.controller.page;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.page.PageModelDTO;
import com.gimi.cloud.bbp.manage.service.page.PageModelService;

/**
 * 模块
 * @author zhoufuhang
 *
 */
@RestController
public class PageModelController {

	@Autowired private PageModelService modelService;
	
	/**
	 * 获取模块列表
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/getPageModelList")
	public Response getList(@RequestBody PageModelDTO dto, HttpServletResponse response) {
		return new Response(ResponseCodeEnum.SUCCESSED, modelService.getList(dto));
	}
	
	/**
	 * 删除模块
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/delPageModel")
	public Response delInfo(@RequestBody PageModelDTO dto, HttpServletResponse response) {
		modelService.delInfo(dto.getIds());
		return new Response(ResponseCodeEnum.SUCCESSED);
	}
	
	/**
	 * 保存模块
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/savePageModel")
	public Response saveInfo(@RequestBody PageModelDTO dto, HttpServletResponse response) {
		modelService.saveInfo(dto);
		return new Response(ResponseCodeEnum.SUCCESSED);
	}
	
	/**
	 * 获取模块
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/getPageModel")
	public Response getInfo(@RequestBody PageModelDTO dto, HttpServletResponse response) {
		return new Response(ResponseCodeEnum.SUCCESSED,modelService.getInfoById(dto.getId()));
	}
}
